<?php

namespace App\Services\Member;

use App\Models\Member\Like;

use Illuminate\Routing\Route;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Request;

class LikeService
{
    /**
     * 对某类型的某uuid点赞总数量
     * @param $place
     * @param $uuid
     * @return num
     * @throws \Exception
     */
    public static function sumLike(string $place = '', string $uuid = '')
    {
        $like_where[] = ['service_uuid', '=', $uuid];
        $like_where[] = ['place', '=', $place];
        $count = Like::where($like_where)->count();
        return $count;//
    }

    /**
     * 某类型的某uuid是否已经点赞
     * @param $member_uuid
     * @param $place
     * @param $uuid
     * @return num
     * @throws \Exception
     */
    public static function hasLike(string $member_uuid = '', string $place = '', string $uuid = '')
    {
        $like_where[] = ['member_uuid', '=', $member_uuid];
        $like_where[] = ['service_uuid', '=', $uuid];
        $like_where[] = ['place', '=', $place];
        $count = Like::where($like_where)->count();

        return $count >=1 ? 1 : 0;//1是已经点赞0，是未点赞
    }

}
